package com.apps.ftapp.adapter;

import com.apps.ftapp.util.Tools;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * Created by lyli on 2017/10/11.
 */

public class Singleton {


    /* 持有私有静态实例，防止被引用，此处赋值为null，目的是实现延迟加载 */
    private static Singleton instance = null;

    private List<Map> datas = new ArrayList<>();

    private List<Map> datiList = new ArrayList<>();

    private String startTime;

    private String endTime;

    private String id;

    private String keys = "";
    private String lmname = "";

    /**
     * 类型 0  先来十题   1 题 库练习
     */
    private static String type = "";


    /* 私有构造方法，防止被实例化 */
    private Singleton() {
    }

    /* 1:懒汉式，静态工程方法，创建实例 */
    public static Singleton getInstance() {
        if (instance == null) {
            instance = new Singleton();
        }
        return instance;
    }

    public static String getType() {
        return type;
    }

    public static void setType(String type) {
        Singleton.type = type;
    }

    public List<Map> getDatiList() {
        return datiList;
    }

    public void setDatiList(List<Map> datiList) {
        this.datiList = datiList;
    }

    public void updDatiList(int index, boolean flag) {
        for (Map tmp : this.datiList) {
            if (Tools.isIntNull(tmp.get("index")) == index) {
                tmp.put("is", flag);
            }
        }
    }

    public void updateans(String index, String ans) {
        for (Map map : this.datas) {
            if (String.valueOf(map.get("id")).equals(index)) {
                map.put("ans", ans);
            }
        }
    }


    public void clearDati() {
        this.datiList.clear();
    }


    public void addD(Map map) {
        this.datiList.add(map);
    }

    public String getStartTime() {
        return startTime;
    }

    public void setStartTime(String startTime) {
        this.startTime = startTime;
    }

    public String getEndTime() {
        return endTime;
    }

    public void setEndTime(String endTime) {
        this.endTime = endTime;
    }

    public List<Map> getDatas() {
        return datas;
    }

    public void setDatas(List<Map> datas) {
        this.datas = datas;
    }


    public void addData(Map map) {
        this.datas.add(map);
    }


    public void clear() {
        this.datas.clear();
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getKeys() {
        return keys;
    }

    public void setKeys(String keys) {
        this.keys = keys;
    }

    public String getLmname() {
        return lmname;
    }

    public void setLmname(String lmname) {
        this.lmname = lmname;
    }
}
